package com.dudsbury.jtablestuff;

import java.awt.Component;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;


import com.dudsbury.database.Booking;

import com.dudsbury.database.Booking;

public class CustomTableCellRenderer extends DefaultTableCellRenderer implements MouseListener {
	public Component getTableCellRendererComponent(JTable table,
			Object booking, boolean isSelected, boolean hasFocus, int row,
			int column) {
		Component cell = super.getTableCellRendererComponent(table, booking,
				isSelected, hasFocus, row, column);
		
		cell.addMouseListener(this);
		// Integer amount = (Integer) value;
		if (booking != null) {
			this.setHorizontalAlignment(SwingConstants.CENTER);
			cell.setBackground(Color.GREEN);
			// You can also customize the Font and Foreground this way
			// cell.setForeground();
			// cell.setFont();
		} else {


			cell.setBackground(Color.WHITE);

		}

		return cell;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	
		System.out.println("Cell Renderer Mouse Clicked");
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
